package com.jiayang.hhotel.presenter;

import android.app.AlertDialog;
import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.ui.AddedContractActivity;
import com.jiayang.hhotel.util.CommonUtil;

import cn.droidlover.xdroidmvp.mvp.XPresent;

/**
 * Created by Administrator on 2017/5/26 0026.
 * 新增合同逻辑类
 */

public class AddedContractPresenter extends XPresent<AddedContractActivity> {

    AlertDialog addContractDialog;
    private Uri imageUri;//图片uri
    /**
     * 创建选择图片来源对话框
     * @param context 上下文
     */
    public void createSelPictureDialog(final Context context){
        final AlertDialog.Builder builder=new AlertDialog.Builder(context);
        View itemView= LayoutInflater.from(context).inflate(R.layout.dialog_picture_from_select,null);
        Button camera= (Button) itemView.findViewById(R.id.bt_photo);
        Button album= (Button) itemView.findViewById(R.id.bt_album);
        Button cancel= (Button) itemView.findViewById(R.id.bt_cancel);
        camera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                addContractDialog.dismiss();
                imageUri=CommonUtil.startCamera(context);
            }
        });
        album.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                addContractDialog.dismiss();
                CommonUtil.startAlbum(context);
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                addContractDialog.dismiss();
            }
        });
        builder.setView(itemView);
        addContractDialog =builder.show();
    }

    /**
     * 获取图片uri
     * @return uri
     */
    public Uri getImageUri(){
        return imageUri;
    }
}
